home *** CD-ROM | disk | FTP | other *** search
Text File | 2007-06-27 | 102.6 KB | 3,008 lines |
- // author: Chuck Baker
- // contact: febe@customsoftwareconsult.com
- // Version 5.0
-
- window.addEventListener("load",febeLoad,true);
-
- function febeLoad(){
- febeSetMsgs();
-
- // See if this is a new install
- var version = getFebeVersion();
- var newInstall = false;
- var prefName = "extensions.febe.previousversion";
- if(febePrefs.prefHasUserValue(prefName)){
- var pversion = febePrefs.getCharPref(prefName);
- if (pversion != version){newInstall = true;}
- }else{
- newInstall = true;
- }//if
-
- if(newInstall == true){
- var tmp = febeMsg[155]+"\n\n";
- var style = "<style>color: black;font-size: 12pt;</style>";
- tmp += style+febeMsg[156]+"\n";
- style = "<style>color: black; font-size: 10pt;</style>"
- tmp += style+febeMsg[157]+"\n";
- style = "<style>font-style: italic; color: black; font-size: 10pt;</style>"
- tmp += style+febeMsg[158];
- febeAlert(tmp)
- febePrefs.setCharPref(prefName,version);
- }//if
-
-
- // See if a bookmark restore is in progress
- var prefName = "extensions.febe.restoreBookmarks";
- if(febePrefs.prefHasUserValue(prefName)){
- if (febePrefs.getBoolPref(prefName)){
- febeRestoreBookmarksFinish();
- }//if
- }//if
-
- // See if a username-password restore is in progress
- var prefName = "extensions.febe.restorePasswords";
- if(febePrefs.prefHasUserValue(prefName)){
- if (febePrefs.getBoolPref(prefName)){
- febeRestorePasswordsFinish();
- }//if
- }//if
-
- // See if a phishing data restore is in progress
- var prefName = "extensions.febe.restorePhishingData";
- if(febePrefs.prefHasUserValue(prefName)){
- if (febePrefs.getBoolPref(prefName)){
- febeRestorePhishingDataFinish()
- }//if
- }//if
-
- // See if a browser history restore is in progress
- var prefName = "extensions.febe.restoreHistory";
- if(febePrefs.prefHasUserValue(prefName)){
- if (febePrefs.getBoolPref(prefName)){
- febeRestoreBrowserHistoryFinish();
- }//if
- }//if
-
- febeRemind();
- febeScheduleBackup();
- return true;
- }//febeLoad()
-
- function febeRemind(){
- // See if we need to remind about a backup
- if(febeReminded == true){return true;}
- var prefName = "extensions.febe.reminderdays";
- var reminderDays = new Number(0);
- if(febePrefs.prefHasUserValue(prefName)){
- reminderDays = febePrefs.getIntPref(prefName);
- }//if
- if(reminderDays <= 0){return true;}
- var prefName = "extensions.febe.lastbackup";
- if(!febePrefs.prefHasUserValue(prefName)){return true;}
- var lastBU = febePrefs.getCharPref(prefName);
- var lDate = Date.parse(lastBU);
- var now = Date.parse(Date());
- var elapsed = (now - lDate) / (24 * 60 * 60 * 1000); // Number of days since last backup
- if(elapsed >= reminderDays){
- var tmp = "<style>color: red; font-weight: bold; font-size: 20px;</style>"+febeMsg[171]+"\n";
- tmp += "<style>color: black;</style>"+febeMsg[172].replace("%days%",parseInt(elapsed))+"\n";
- tmp += febeLocalizedDate(lastBU);
- febeAlert(tmp);
- febeReminded = true;
- }//if
- return true;
- }//febeRemind()
-
- function febeGetEnvironmentVariableValue(envString){
- var env = Components.classes["@mozilla.org/process/environment;1"]
- .createInstance(Components.interfaces.nsIEnvironment);
- return env.get(envString);
- }//febeGetEnvironmentVariableValue
-
- function febeInit(){
- //alert("febeInit")
- febeVersion = febeMsg[49]+" "+getFebeVersion();
- febeGetPrefs();
-
- // See if destination directory exists
- var prefName = "extensions.febe.extBUdir";
- if(febePrefs.prefHasUserValue(prefName)){
- febeExBuDir = febeGetUnicharPref(prefName);
- if(febeExBuDir == ""){
- if(febePlatform == 1){febeExBuDir = "C:\\";}
- if(febePlatform == 2){febeExBuDir = "/";}
- if(febePlatform == 3){febeExBuDir = "/";}
- }//if
- febeBuDesDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- febeBuDesDir.initWithPath(febeExBuDir);
- if (!(febeBuDesDir.exists() && febeBuDesDir.isDirectory())){
- febeAlert(febeMsg[0]+" \""+febeExBuDir+"\" "+febeMsg[1]+"\n"+febeMsg[2]);
- return false;
- }//if
- } else {
- febeAlert(febeMsg[3]+"\n"+febeMsg[4]);
- return false;
- }//if
-
- // Create timestamped directory if needed
- if(febeUseTimestampedDir){
- febeDelTimestampDirs();
- var d=new Date();
- var YYYY = String(d.getFullYear());
- var MM = String(d.getMonth()+1);
- if(MM.length == 1){MM = "0" + MM;}
- var DD = String(d.getDate());
- if(DD.length == 1){DD = "0" + DD;}
- var hh = String(d.getHours());
- if(hh.length == 1){hh = "0" + hh;}
- var mm = String(d.getMinutes());
- if(mm.length == 1){mm = "0" + mm;}
- var ss = String(d.getSeconds());
- if(ss.length == 1){ss = "0" + ss;}
- var timestamp = "FEBE "+YYYY+" "+MM+"-"+DD+" "+hh+"."+mm+"."+ss;
- //var timestamp = "FEBE "+YYYY+" "+MM+"-"+DD+" "+hh+"-"+mm+"-"+ss;
- febeBuDesDir.append(timestamp);
- if(!febeBuDesDir.exists() || !febeBuDesDir.isDirectory()){
- febeBuDesDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
- }//if
- febeExBuDir = febeBuDesDir.path;
- }//if
-
- if(!febeSanityCheck()){return false;}
- if(!febeInitDir()){return false;}
- if(!febeClearDir()){return false;}
- febeStartBackup();
- return true;
- }//febeInit()
-
- function febeDelTimestampDirs(){
- // Delete timestamped directories if needed
- if(febeMaxDirs == 0){return;} // No limit
- var dirArray = [];
- var mask = /^FEBE \d\d\d\d \d\d-\d\d \d\d\.\d\d\.\d\d$/;
- var buDirRoot = febeBuDesDir.clone();
- var buDirParent = buDirRoot.parent.path;
- var entries = buDirRoot.directoryEntries;
-
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- var dirName = entry.leafName;
- if(!entry.isDirectory()){continue;}
- if(!dirName.match(mask)){continue;}
- dirArray.push(dirName);
- }
- var numDirsToDelete = dirArray.length - febeMaxDirs + 1;
- dirArray.sort();
- for(var i=0; i<numDirsToDelete; i++){
- var rmDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- rmDir.initWithPath(buDirRoot.path);
- rmDir.append(dirArray[i]);
- rmDir.remove(true);
- }//for
- return true;
- }//febeDelTimestampDirs()
-
- function febeAbortBackup(){
- // Abort scheduled backup before it starts (only if statusbar icon is in "warning" state)
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- var d = win.document.getElementById("febestatusbar");
- if(d){
- var status = d.getAttribute("status");
- switch(status){
- case "warning":
- var tmp="<style>color: red; font-weight: bold; font-size: 20px;</style>"+febeMsg[179];
- if(!febeConfirm(tmp)){return;}
- for(var i in febeSetTimeoutID){
- var to = new febeSetTimeoutObj;
- to.PID = febeSetTimeoutID[i].PID;
- to.Process = febeSetTimeoutID[i].Process;
- clearTimeout(to.PID);
- }//for
- febeSetTimeoutID = [];
- var tmp = "<style>color: red; font-weight: bold;</style>"+febeMsg[150]+"\n";
- tmp += "<style>color: black; font-weight: bold;</style>"+febeMsg[151]+"\n";
- tmp += "<style>color: black; font-weight: normal;</style>"+febeMsg[152]+"\n";
- febeAlert(tmp);
- febeBuInProgress = true; // In case it tries to start, just say no ...
-
- // Turn off scheduled backups
- var prefName = "extensions.febe.schedule.frequency";
- febePrefs.setCharPref(prefName,"none");
- febeScheduleBackup();
- break;
- case "normal":
- var prefName = "extensions.febe.schedule.description";
- var tmp = "<style>color: blue; font-weight: normal;</style>"+febeMsg[114]+"\n";
- tmp += "<style>color: black; font-weight: normal;font-family: courier;</style>"+febeGetUnicharPref(prefName);
- febeAlert(tmp);
- break;
- case "nobackup":
- var tmp = "<style>color: blue; font-weight: normal; font-size: 12px;</style>"+febeMsg[113];
- febeAlert(tmp);
- break;
- }//switch
-
- //d.class = "statusbarpanel-iconic febe-normal";
- //d.setAttribute("status","normal");
- }//if
- return true;
- }//febeAbortBackup()
-
- function febeCopyZips(){
- if(febePlatform == 1){
- // Copy the zip utilities to the temp directory (febe.tmp)
- febeCopyFile(febeZipFile.path,febeTmpDir.path,FEBEWINZIPFILENAME);
- febeCopyFile(febeUnZipFile.path,febeTmpDir.path,FEBEWINUNZIPFILENAME);
- }//if
- }//febeCopyZips()
-
- function febeSanityCheck(){
- // Check to see if there is anything to backup
- var OK = (
- buExtensions ||
- buThemes ||
- buBookmarks ||
- buPreferences ||
- buCookies ||
- buUserChrome ||
- buUserContent ||
- buUserPwd ||
- buPhishingData ||
- buSearchPlugins ||
- buBrowserHistory ||
- buFormFillHistory ||
- buPermissions ||
- buUDBu ||
- includeFEBE ||
- buProfile);
- if(!OK){febeAlert(febeMsg[131]);}
- return OK;
- }//febeSanityCheck()
-
- function doFebeBackup(){
- febeBuInProgress = true;
- if(!buProfile){
- febeBackupExtensions();
- febeBackupBookmarks();
- febeBackupPreferences();
- febeBackupCookies();
- febeBackupUserChrome();
- febeBackupUserContent();
- febeBackupPasswords();
- febeBackupPhishingData();
- febeBackupSearchPlugins();
- febeBackupBrowserHistory();
- febeBackupFormFillHistory();
- febeBackupPermissions();
- febeBackupUDBu();
- upBackedUp = false;
- }else{
- febeBackupProfile();
- }
- febeIncludeFEBE();
- febeWriteResults();
- febeStoreBUdate();
- febeBuInProgress = false;
- febeScheduleBackup(); // Schedule the next backup
- if (febeDebugMode == false){febeTmpDir.remove(true)};
- if(febeWin){febeWin.close();}
- return true;
- }//doFebeBackup()
-
- function febeStoreBUdate(){
- // Write last backup date to preferences
- var prefName = "extensions.febe.lastbackup";
- var dflt = new Date();
- febeSetUnicharPref(prefName,dflt);
- return true;
- }//febeStoreBUdate()
-
- function febeIncludeFEBE(){
- // Include a copy of FEBE with backup
- if(!includeFEBE){return;}
- var extDir = febeProfDir.clone();
- extDir.append("extensions");
- extDir.append(FEBE_GUID);
-
- var thisExt = new febeExtInfo(FEBE_GUID);
- exBackedUp = true;
- var extName = "FEBE";
- var extIcon = thisExt.iconURL;
- var extHome = thisExt.homepageURL;
- var batchFileName = extName;
- var extBuName = batchFileName+".xpi";
- var srcName = extDir.clone();
- srcName = srcName.path;
- febeDestDir = febeTmpDir.clone();
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- febeSubRootDir = FEBE_GUID;
- febeDirCopy(extDir.path);
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEzip.exe\"");
- batchlines.push("SET SRCDIR="+"\""+FEBE_GUID+"\"");
- batchlines.push("SET SRCNAME="+"*");
- batchlines.push("SET DEST=\"..\\FEBE.xpi\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("CD %SRCDIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+extBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+extBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){ // Copy the backup to the destination directory
- febeCopyFile(febeTmpDir.path+"\\"+extBuName,febeExBuDir,extBuName);
- }//if
- var item = new febeExtObj;
- item.Name = batchFileName;
- item.Path = "";
- item.Icon = extIcon;
- item.Home = extHome;
- item.guid = FEBE_GUID;
- item.verified = febeVerify(extBuName);
- febeExtensionsList[item.Name] = item;
- febeExtensionsList["**total**"]++;
- }else{
- febeAlert(batchFileName+" failed")
- }//if
- return true;
- }//febeIncludeFEBE()
-
- function febeWriteResults(){
- // Create results page
- febeUpdateProgressWindow(febeMsg[77]);
-
- // Pointer to results page html file
- var febeResultsPage = FEBEdir.clone();
- febeResultsPage.append("FEBEresults.html");
-
- // Open results page for writing
- var resultsFile = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- resultsFile.init(febeResultsPage, 0x02 | 0x08 | 0x20, 0755, 0); // write, create, truncate
-
- // Get results template
- var resultsTemplate=getFebeResultsTemplate("chrome://febe/content/FEBEresultsTemplate.html")
-
- // Add results to results page
- var middle = new String();
- var cnt = 0;
-
- // Create the new content
- var numExt = parseInt(febeExtensionsList["**total**"]);
- var numThemes = parseInt(febeThemesList["**total**"]);
-
- delete febeExtensionsList["**total**"];
- delete febeThemesList["**total**"];
-
- // Sort using key array
- var febeExtKey = [];
- var febeThemeKey = [];
- for(var i in febeExtensionsList){
- febeExtKey.push(febeExtensionsList[i].Name);
- }//for
-
- for(var i in febeThemesList){
- febeThemeKey.push(febeThemesList[i].Name);
- }//for
- febeExtKey.sort();
- febeThemeKey.sort();
-
- var total = numExt + numThemes;
- if (bmBackedUp){total++};
- if (prBackedUp){total++};
- if (ckBackedUp){total++};
- if (chBackedUp){total++};
- if (ucBackedUp){total++};
- if (pwBackedUp){total++};
- if (pdBackedUp){total++};
- if (spBackedUp){total++};
- if (hsBackedUp){total++};
- if (ffBackedUp){total++};
- if (pmBackedUp){total++};
- if (upBackedUp){total++};
- total += udBackedUp;
-
- var re = new RegExp("\\\\", "g");
- var errCnt = 0;
- var warnCnt = 0;
- var imgstyle = ' height="16" width="16" '
- var table = ['<table border="0" cellpadding="2" cellspacing="2">\n<tbody>',"</tbody>\n</table>"];
- var tr = ["<tr>\n","</tr>\n"];
- var tdnum = ['<td style="vertical-align: middle; text-align: right;"><num>'
- ,"</num></td>\n"];
- var tdimg = ['<td style="text-align: center;">','</td>\n'];
- var tdnolink = ['<td style="font-weight: bold;"><nolink>','</nolink></td>\n'];
- var tdlink = ['<td style="font-weight: bold;">','</td>\n']
- var tdguid = ['<td><guid>','</guid></td>\n'];
- var div = ['<div style="text-align:left; direction: ltr;">\n',"</div>\n"];
- //var disabledIndicator = "<ds> (D)</ds>";
- var disabledIndicator = '<img src="chrome://febe/skin/disabled.png"'+imgstyle+'>';
-
- if (febeDebugMode == true){
- middle += "<i>"+febeMsg[8]+"<br>\n";
- middle += febeMsg[76]+" ";
- middle +=' <a href=\"file://'+febeTmpDir.path.replace(re,"/")+'\">'+ febeTmpDir.path;
- middle +="</a><br></i>\n";
- }//if
- middle += "<p><b>"+febeMsg[12]+" </b> "+total+" "+febeMsg[13];
- middle += " <i>("+febeMsg[15]+' <a href=\"file://'+febeExBuDir.replace(re,"/")+'\">'+febeExBuDir+"</a>)</i></p>\n";
- //middle += div[0];
- if ((total) != 0){
- if (numExt != 0){
- middle += "<p>"+febeMsg[14]+" ("+numExt+" "+febeMsg[13]+")\n";
- if(febeDisabledCount != 0){
- middle += "<i>("+febeMsg[107].replace("%num%",febeDisabledCount)+")</i>\n";
- }else{
- middle += " - "+febeMsg[120].replace("%disabled%",disabledIndicator)+"\n";
- }//if
- middle += "</p>\n"+div[0]+table[0];
- var item = new febeExtObj;
- for(var i=0; i<febeExtKey.length; i++){
- var key = febeExtKey[i];
- item = febeExtensionsList[key];
- if(item.verified == false){
- febeErrorList.push(febeMsg[18]+" "+item.Name);
- errCnt++;
- continue;
- }//if
- cnt++;
- middle += tr[0];
- middle += tdnum[0]+cnt+"."+tdnum[1];
- middle += tdimg[0]+"<img src='"+item.Icon+"'"+imgstyle+">"+tdimg[1];
- var thisExt = new febeExtInfo(item.guid);
- var tmp = item.Name;
- if(thisExt.isDisabled){
- tmp = "<i>"+tmp+"</i>";
- }else{
- tmp = tmp;
- }//if
- if(item.Home != ""){
- middle += tdlink[0]+"<a href="+item.Home+">"+tmp+"</a>"+tdlink[1];
- }else{
- middle += tdnolink[0]+tmp+tdnolink[1];
- }//if
- if(febeDebugMode == true){middle += tdguid[0]+"GUID "+item.guid+tdguid[1];}
- middle += tr[1];
- }//for
- middle += table[1]+div[1];
- }//if
-
- if (numThemes != 0){
- cnt = 0;
- middle += "<p>"+febeMsg[16]+" ("+numThemes+" "+febeMsg[13]+")</p>\n";
- middle += div[0]+table[0];
- var item = new febeExtObj;
- for(var i=0; i<febeThemeKey.length; i++){
- var key = febeThemeKey[i];
- item = febeThemesList[key];
- if(item.verified == false){
- febeErrorList.push(febeMsg[18]+" "+item.Name);
- errCnt++;
- continue;
- }//if
- cnt++;
- middle += tr[0];
- middle += tdnum[0]+cnt+"."+tdnum[1];
- middle += tdimg[0]+"<img src='"+item.Icon+"'"+imgstyle+">"+tdimg[1];
- var tmp = item.Name;
- if(item.Home){
- middle += tdlink[0]+"<a href="+item.Home+">"+tmp+"</a>"+tdlink[1];
- }else{
- middle += tdnolink[0]+tmp+tdnolink[1];
- }//if
- if(febeDebugMode == true){middle += tdguid[0]+"GUID "+item.guid+tdguid[1];}
- middle += tr[1];
- }//for
- middle += table[1]+div[1];
- }//if
- //middle += div[1];
- }else{
- febeErrorList.push("<p>"+febeMsg[19]+"</p>\n");
- errCnt++;
- }//if
-
- //middle += div[0]+"<p>";
- middle += "<p>";
- if(!buProfile){
- // Optional backups
- if (buBookmarks){
- if (bmBackedUp){
- middle +=febeMsg[27]+" <b>"+bmBuName+"</b><br>\n"
- }else{
- febeErrorList.push(febeMsg[30]);
- errCnt++;
- }//if
- }//if
- if (buPreferences){
- if (prBackedUp){
- middle +=febeMsg[28]+" <b>"+prBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[31]);
- warnCnt++;
- }//if
- }//if
- if (buCookies){
- if (ckBackedUp){
- middle +=febeMsg[29]+" <b>"+ckBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[32]);
- warnCnt++;
- }//if
- }//if
- if (buUserChrome){
- if (chBackedUp){
- middle +=febeMsg[52]+" <b>"+chBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[60]);
- warnCnt++;
- }//if
- }//if
- if (buUserContent){
- if (ucBackedUp){
- middle +=febeMsg[53]+" <b>"+ucBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[61]);
- warnCnt++;
- }//if
- }//if
- if (buUserPwd){
- if (pwBackedUp){
- middle +=febeMsg[54]+" <b>"+pwBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[62]);
- warnCnt++;
- }//if
- }//if
- if (buPhishingData){
- if (pdBackedUp){
- middle +=febeMsg[55]+" <b>"+pdBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[63]);
- warnCnt++;
- }//if
- }//if
- if (buSearchPlugins){
- if (spBackedUp){
- middle +=febeMsg[56]+" <b>"+spBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[64]);
- warnCnt++;
- }//if
- }//if
- if (buBrowserHistory){
- if (hsBackedUp){
- middle +=febeMsg[57]+" <b>"+hsBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[65]);
- warnCnt++;
- }//if
- }//if
- if (buFormFillHistory){
- if (ffBackedUp){
- middle +=febeMsg[58]+" <b>"+ffBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[66]);
- warnCnt++;
- }//if
- }//if
- if (buPermissions){
- if (pmBackedUp){
- middle +=febeMsg[116]+" <b>"+pmBuName+"</b><br>\n"
- }else{
- febeWarningList.push(febeMsg[115]);
- warnCnt++;
- }//if
- }//if
- if (buUDBu){
- for(var i in febeUDBuDone){
- var item = new febeUDBuDoneObj;
- item.Description = febeUDBuDone[i].Description;
- item.Name = febeUDBuDone[i].Name;
- var tmp = febeMsg[148].replace("%description%","\""+item.Description+"\"");
- tmp = tmp.replace("%name%"," <b>"+item.Name+"</b><br>\n");
- middle += tmp;
- }//for
- }//if
- }else{ // Full profile
- if (upBackedUp){
- middle +=febeMsg[59]+" <b>"+upBuName+"</b><br>\n"
- }else{
- febeErrorList.push(febeMsg[67]);
- errCnt++;
- }//if
- }//if
- //middle += "</p>\n"+div[1];
- middle += "</p>\n";
-
- // Write the final results
- var pageSource = resultsTemplate.replace("%title%", febeMsg[108]);
- pageSource = pageSource.replace("%reportheading%", febeMsg[109]);
- pageSource = pageSource.replace("%version%", febeVersion);
- pageSource = pageSource.replace("%by%", febeMsg[180]);
- pageSource = pageSource.replace("%results%", middle);
- var prefName = "extensions.febe.orientation";
- var orientation = febePrefs.getCharPref(prefName);
- //orientation = "rtl"
- pageSource = pageSource.replace("%orientation%", orientation);
- middle = "";
- if(errCnt != 0){
- pageSource = pageSource.replace("%errmsg%", "<errh>"+errCnt+" "+febeMsg[112]+"</errh>");
- middle = div[0];
- for(var i=0; i<febeErrorList.length; i++){
- middle += "<err>"+febeErrorList[i]+"</err><br>\n";
- }//for
- middle += div[1];
- pageSource = pageSource.replace("%errlist%", middle);
- }else{
- pageSource = pageSource.replace("%errmsg%<br>", "<!-- %errmsg% -->\n");
- pageSource = pageSource.replace("%errlist%<br>", "<!-- %errlist% -->\n");
- }//if
- if(warnCnt != 0){
- pageSource = pageSource.replace("%warnmsg%", "<warnh>"+warnCnt+" "+febeMsg[132]+"</warnh>");
- middle = div[0];
- for(var i=0; i<febeWarningList.length; i++){
- middle += "<warn>"+febeWarningList[i]+"</warn><br>\n";
- }//for
- middle += div[1];
- pageSource = pageSource.replace("%warnlist%", middle);
- }else{
- pageSource = pageSource.replace("%warnmsg%<br>", "<!-- %warnmsg% -->\n");
- pageSource = pageSource.replace("%warnlist%<br>", "<!-- %warnlist% -->\n");
- }//if
- pageSource = pageSource.replace("%hompagemsg%", febeMsg[110]);
- pageSource = pageSource.replace("%linkmsg%", febeMsg[111]);
-
- // Create an UTF-8 output stream
- var charset = "UTF-8";
- var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
- .createInstance(Components.interfaces.nsIConverterOutputStream);
-
- os.init(resultsFile, charset, 4096, 0x0000);
- os.writeString(pageSource);
- os.close();
-
- // Open and display results
- if(errCnt == 0){
- febePlaySound("success");
- }else{
- febePlaySound("failure");
- }//if
- // Thanks to menet for providing the code to display the results page in an unused tab
- // if one is availble.
- var finalPage = "file:///"+febeResultsPage.path
- if(febeDispResults){
- var currBlank = (getBrowser() &&
- (getBrowser().mCurrentTab.linkedBrowser &&
- (getBrowser().mCurrentTab.linkedBrowser.contentDocument.location == "about:blank")) ||
- (!getBrowser().mCurrentTab.linkedBrowser &&
- (getBrowser().mCurrentTab.label == "(Untitled)")));
- if (currBlank){
- var resultsWindow = loadURI(finalPage);
- }else{
- var resultsWindow = openNewTabWith(finalPage, this.docURL, null, null);
- }//if
- }//if
- return true;
- }//febeWriteResults()
-
- function febeWarn(){
- // Display scheduled backup warning in statusbar
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- var d = win.document.getElementById("febestatusbar");
- d.setAttribute("status","warning");
- febePlaySound("warning");
- for(var i=10000; i<= 40000; i += 10000){
- var to = new febeSetTimeoutObj;
- to.PID = setTimeout('febePlaySound("warning")',i)
- to.Process = 'febePlaySound("warning")';
- febeSetTimeoutID.push(to);
- }//for
- return true;
- }//febeWarn()
-
- function febeStripSpaces(extName){
- // Remove spaces and undesirable characters from extension name
- var tmp = "";
- var mask = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- mask += ".+-_";
- for (var i = 0; i <= extName.length; i++){
- var c = extName.charAt(i);
- if( mask.indexOf(c) != -1 ){tmp += c};
- }//for
- return tmp;
- }//febeStripSpaces()
-
- function febeDebug(aMsg) {
- setTimeout(function() { throw new Error("[debug] " + aMsg); }, 0);
- return true;
- }//debug
-
- function febePickFiles(filter,msgNum){
- // Select extension/themes to install
- const nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"]
- .createInstance(nsIFilePicker);
- fp.init(window, febeMsg[msgNum], nsIFilePicker.modeOpenMultiple);
- fp.appendFilter(filter,filter);
-
- // Set the default directory to the backup destination directory
- var prefName = "extensions.febe.extBUdir";
- if(!febePrefs.prefHasUserValue(prefName)){
- febeGetPrefs();
- if(febePlatform == 1){febeExBuDir = "C:\\";}
- if(febePlatform == 2){febeExBuDir = "/";}
- if(febePlatform == 3){febeExBuDir = "/";}
- }else{
- febeExBuDir = febeGetUnicharPref(prefName);
- }//if
-
- if(febeExBuDir != ""){
- var aDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- aDir.initWithPath(febeExBuDir);
- fp.displayDirectory = aDir;
- }//if
-
- var rv = fp.show();
- febeETinstall = [];
- if (rv == nsIFilePicker.returnOK){
- var files = fp.files;
- while(files.hasMoreElements()) {
- var file = files.getNext()
- .QueryInterface(Components.interfaces.nsILocalFile);
- var obj = new febeExtObj;
- obj.Name = file.leafName;
- obj.Path = file.path;
- febeETinstall.push(obj);
- }//while
- }//if
- return true;
- }//febePickFiles()
-
- function febeStartBackup(){
- //alert("febeStartBackup");
- if(febeBuInProgress == true){
- febeBuInProgress = false;
- return true;
- }//if
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- if(win.document.getElementById("febeTLBRbutton")){
- win.document.getElementById("febeTLBRbutton").status = "disabled";
- win.document.getElementById("febeTLBRbutton").hidden = "true";
- }//if
- if(win.document.getElementById("febestatusbar")){
- win.document.getElementById("febestatusbar").hidden = true;
- }//if
- febeBuInProgress = true;
- if(febeDispProgress == true){
- // Open the progress window
- febeWin = openDialog("chrome://febe/content/febeProgress.xul", "FEBE", "chrome,dependent,alwaysRaised,centerscreen,dialog='no'");
- // Give the browser a chance to display the progress window before the backup starts
- setTimeout('doFebeBackup()',1000);
- }else{
- doFebeBackup();
- }//if
- win.document.getElementById("febestatusbar").class = "statusbarpanel-iconic febe-normal";
- win.document.getElementById("febestatusbar").hidden = false;
- win.document.getElementById("febeTLBRbutton").setAttribute("status","normal");
- win.document.getElementById("febeTLBRbutton").setAttribute("hidden","false");
- return true;
- }//febeStartBackup()
-
- function getFebeResultsTemplate(aURL){
- var req = new XMLHttpRequest();
- req.open('GET', aURL, false);
- req.send(null);
- return req.responseText;
- }//getFebeResultsTemplate()
-
- function febeCopyFile(sourcefile,destdir,dName){
- if(dName == "parent.lock"){return true;} // File is locked
- // get a component for the file to copy
- var aFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- if (!aFile) return false;
-
- // get a component for the directory to copy to
- var aDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- if (!aDir) return false;
-
- // next, assign URLs to the file components
- aFile.initWithPath(sourcefile);
- aDir.initWithPath(destdir);
-
- // delete the destination file if it exists
- var oFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- oFile.initWithPath(destdir);
- oFile.append(dName);
- try{
- oFile.remove(false);
- }catch(e){
- //alert(e);
- }
-
- // finally, copy the file, renaming it
- try{
- aFile.copyTo(aDir,dName);
- }catch(e){
- //if(febeIgnoreError == true){return true};
- var msg = febeMsg[168].replace("%sourcefile%",sourcefile+"\n");
- msg = msg.replace("%destdir%",destdir+"\n");
- msg = msg.replace("%dName%",dName);
- febeFatal(e,msg);
- return false;
- }
- return true;
- }//febeCopyFile
-
- function febeDirCopy(sourceDir){
- // Recursively copy individual files and sub-directories to a destination directory
- //
- // Example:
- // sourceDir (intially) = [profiledir]/extensions
- // febeSubRootDir = {4BBDD651-70CF-4821-84F8-2B918CF89CA3}
- // febeDestDir = nsIFile to [temp]/febe.tmp
- //
- // All files and sub-directories in [profiledir]/extensions/{4BBDD651-70CF-4821-84F8-2B918CF89CA3}
- // will be copied to [temp]/febe.tmp/{4BBDD651-70CF-4821-84F8-2B918CF89CA3}
-
- var tmp = "sourceDir: "+sourceDir;
- tmp += "\nfebeSubRootDir: "+febeSubRootDir;
- tmp += "\nfebeDestDir: "+febeDestDir.path;
-
- var aFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- if (!aFile) return false;
-
- aFile.initWithPath(sourceDir);
- var entries = aFile.directoryEntries;
-
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- var src = entry.path;
- var p = src.indexOf(febeSubRootDir)
- if(p == -1){continue;}
- if(entry.isDirectory()){
- febeDirCopy(src);
- }else{
- var parentPath = entry.parent.path;
- var dest = febeDestDir.path+"\\"+parentPath.substring(p);
- var file = entry.leafName;
- febeCopyFile(src,dest,file);
- }//if
- }//while
- return true;
- }//febeDirCopy()
-
- function febePickFile(filter,msgNum){
- // Select a file to restore
- const nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"]
- .createInstance(nsIFilePicker);
- fp.init(window, febeMsg[msgNum], nsIFilePicker.modeOpen);
- fp.appendFilter(filter,filter);
-
- // Set the default directory to the backup destination directory
- var prefName = "extensions.febe.extBUdir";
- if(!febePrefs.prefHasUserValue(prefName)){
- febeGetPrefs();
- if(febePlatform == 1){febeExBuDir = "C:\\";}
- if(febePlatform == 2){febeExBuDir = "/";}
- if(febePlatform == 3){febeExBuDir = "/";}
- }else{
- febeExBuDir = febeGetUnicharPref(prefName);
- }//if
- if(febeExBuDir != ""){
- var aDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- aDir.initWithPath(febeExBuDir);
- fp.displayDirectory = aDir;
- }//if
-
- var rv = fp.show();
- if (rv == nsIFilePicker.returnOK){
- rv = fp.file;
- febePathName = rv.path;
- febePrName = rv.leafName; // Used in restore profile
- return true;
- }//if
- return false;
- }//febePickFile()
-
- function febeConfirmRestore(msgNum,bDate){
- var style = "<style>color: red;font-size: 14pt;</style>";
- var tmp = style+febeMsg[36] +"\n";
- tmp += febeMsg[msgNum] + "\n";
- tmp += febeLocalizedDate(bDate) +"\n\n";
- tmp += febeMsg[45] + "\n" + febeMsg[40];
- tmp += "\n" + febeMsg[41];
- return febeConfirm(tmp);
- }//febeConfirmRestore()
-
- function febeGetBuDate(filename){
- var oFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- oFile.initWithPath(filename);
- febeBUdate = new Date(oFile.lastModifiedTime);
- return true;
- }//febeGetBuDate()
-
- function febeGoBatch(batchFileName,batchlines){
- febeUpdateProgressWindow(batchFileName);
- switch (febePlatform) {
- case 1: return febeGoBatchWin(batchFileName,batchlines); break; // Windows
- case 2: return febeGoBatchNix(batchFileName,batchlines); break; // Unix
- case 3: return febeGoBatchMac(batchFileName,batchlines); break; // Mac
- default: return false;
- }//switch
- }//febeGoBatch()
-
-
- function febeGoBatchWin(batchFileName,batchlines){ // Run the windows script
- // Create the batch file, open it for write, assign it to a UTF-8 output stream
- try{
- var febeBatch = febeTmpDir.clone();
- febeBatch.append(batchFileName+febeBuSeq+".bat");
- febeBatch.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0755);
- febeBatch = febeBatch.clone();
-
- var febeBatchFile = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- febeBatchFile.init(febeBatch, 0x02 | 0x08 | 0x20, 0755, 0); // write, create, truncate
-
- var charset = "UTF-8";
- var osBatchFile = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
- .createInstance(Components.interfaces.nsIConverterOutputStream);
- osBatchFile.init(febeBatchFile, charset, 4096, 0x0000);
-
- // Build the batch file
- batchlines.unshift("@TITLE "+febeMsg[26]+" "+batchFileName+febeExtExt);
- batchlines.unshift("@PROMPT FEBE: ");
- if(febeDebugMode == true){batchlines.push("@PAUSE");}
- batchlines.push("EXIT");
-
- osBatchFile.writeString(batchlines.join(febeNLchar));
- osBatchFile.close();
- febeMakeExecutable(febeBatch.path);
-
- // Run the batch file
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
-
- file.initWithPath(FEBEbg.path);
- process = Components.classes["@mozilla.org/process/util;1"]
- .createInstance(Components.interfaces.nsIProcess);
- process.init(file);
- // freeze until zipping is complete
- var quote = "\"";
- var vbWindowOpt = "0,";
- if(febeDebugMode == true){vbWindowOpt = "1,";}
- var argv = [vbWindowOpt,febeBatch.path];
-
- //setTimeout("process.run(true, argv, argv.length)",500);
- process.run(true, argv, argv.length);
- return true;
- }catch(e){
- var msg = febeMsg[169];
- febeFatal(e,msg);
- return false;}
- }//febeGoBatchWin()
-
- function febeVerify(verifyFileName){
- // Verify backup was created
- if(febeBuInProgress == false){return true;} // Don't verify restores
- if(febeVerifyBackups == false){return true;}
-
- // Check for existance of backup file every second for a maximum of 10 seconds
- for(var i=0; i<5; i++){
- var chkFile = febeBuDesDir.clone();
- chkFile.append(verifyFileName);
- if(chkFile.exists()){return true;}
- febePause(1000);
- }//for
- return false;
- }//febeVerify()
-
- function febeGoBatchNix(batchFileName,batchlines){ // Run the *nix script
- // Create the batch file, open it for write, assign it to a UTF-8 output stream
- try{
- var febeBatch = febeTmpDir.clone();
- febeBatch.append(batchFileName+febeBuSeq+".sh");
- febeBatch.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0755);
- febeBatch = febeBatch.clone();
-
- var febeBatchFile = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- febeBatchFile.init(febeBatch, 0x02 | 0x08 | 0x20, 0755, 0); // write, create, truncate
-
- var charset = "UTF-8";
- var osBatchFile = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
- .createInstance(Components.interfaces.nsIConverterOutputStream);
- osBatchFile.init(febeBatchFile, charset, 4096, 0x0000);
-
- // Build the batch file
- batchlines.unshift("echo "+febeMsg[26]+" "+batchFileName+febeExtExt);
- batchlines.unshift("PS1=FEBE: ");
- batchlines.unshift("pwd");
- //if(febeDebugMode == true){batchlines.push("read ");}
- batchlines.push("exit");
-
- osBatchFile.writeString(batchlines.join(febeNLchar));
- osBatchFile.close();
- febeMakeExecutable(febeBatch.path);
-
- // Run the batch file
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath("/");
- file.append("bin");
- file.append("sh");
- var process = Components.classes["@mozilla.org/process/util;1"]
- .createInstance(Components.interfaces.nsIProcess);
- process.init(file);
-
- // freeze until zipping is complete
- var argv = ["-cv","\""+febeBatch.path+"\""];
-
- //setTimeout("yourfunction()",1000);
- process.run(true, argv, argv.length);
- return true;
- }catch(e){
- var msg = febeMsg[169];
- febeFatal(e,msg);
- return false;}
- }//febeGoBatchNix()
-
- function febeGoBatchMac(batchFileName,batchlines){ // Run the Mac script
- // Create the batch file, open it for write, assign it to a UTF-8 output stream
- try{
- var febeBatch = febeTmpDir.clone();
- febeBatch.append(batchFileName+febeBuSeq+".sh");
- febeBatch.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0755);
- febeBatch = febeBatch.clone();
-
- var febeBatchFile = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- febeBatchFile.init(febeBatch, 0x02 | 0x08 | 0x20, 0777, 0); // write, create, truncate
-
- var charset = "UTF-8";
- var osBatchFile = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
- .createInstance(Components.interfaces.nsIConverterOutputStream);
- osBatchFile.init(febeBatchFile, charset, 4096, 0x0000);
-
- // Build the batch file
- batchlines.unshift("echo "+febeMsg[26]+" "+batchFileName+febeExtExt);
- batchlines.unshift("PS1=FEBE: ");
- batchlines.unshift("pwd");
- //if(febeDebugMode == true){batchlines.push("read ");}
- batchlines.push("exit");
-
- osBatchFile.writeString(batchlines.join(febeNLchar));
- osBatchFile.close();
- febeMakeExecutable(febeBatch.path);
-
- // Run the batch file
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath("/");
- file.append("bin");
- file.append("sh");
- var process = Components.classes["@mozilla.org/process/util;1"]
- .createInstance(Components.interfaces.nsIProcess);
- process.init(file);
-
- // freeze until zipping is complete
- var argv = ["-cv","\""+febeBatch.path+"\""];
-
- //setTimeout("yourfunction()",1000);
- process.run(true, argv, argv.length);
- return true;
- }catch(e){
- var msg = febeMsg[169];
- febeFatal(e,msg);
- return false;}
- }//febeGoBatchMac()
-
- function febeRestartFx(){
- // Borrowed from Jed Brown's "Restart Firefox" extension
- a = Components.interfaces.nsIAppStartup,Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(a).quit(a.eRestart | a.eAttemptQuit);
- return true;
- }//febeRestartFx()
-
- function febePause(millis){
- date = new Date();
- var curDate = null;
-
- do { var curDate = new Date(); }
- while(curDate-date < millis);
- return true;
- }//febePause()
-
- function febeUpdateProgressWindow(pMsg){
- if(febeBuInProgress == false){return true;}
- if(febeDispProgress == false){return true;}
- var pMsgField = febeWin.document.getElementById("febeProgressText");
- pMsgField.setAttribute("value",pMsg);
- return true;
- }//febeUpdateProgressWindow()
-
- function febePauseUI(){
- //alert("updating progress window");
- //setTimeout(';',500);
- //febeWin.moveBy(5,5);
- febeWin.refresh();
- //febePause(1000);
- return true;
- }//febePauseUI
-
- function febeInitDir(){
- exBackedUp = false;
- thBackedUp = false;
- bmBackedUp = false;
- prBackedUp = false;
- ckBackedUp = false;
- chBackedUp = false;
- ucBackedUp = false;
- pwBackedUp = false;
- pdBackedUp = false;
- spBackedUp = false;
- hsBackedUp = false;
- ffBackedUp = false;
- pmBackedUp = false;
- upBackedUp = false;
-
- // Get platform
- febePlatform = febeGetPlatform();
-
- // Create pointers to needed directories
- // Create a temporary directory to work in
- febeGetTmpDirectory(true);
-
- // Get pointer to FEBE extension directory
- FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
- .getService(Components.interfaces.nsIExtensionManager)
- .getInstallLocation(FEBE_GUID)
- .getItemLocation(FEBE_GUID);
-
- // Get pointers to zip and unzip files
- febeZipFile = FEBEdir.clone();
- febeUnZipFile = FEBEdir.clone();
-
- switch (febePlatform) {
- case 1: // Windows
- febeNLchar = "\r\n"; // Windows CF-LF
- febeSetUnicharPref("extensions.febe.winpathzip",febeZipFile.path);
- febeSetUnicharPref("extensions.febe.winpathunzip",febeUnZipFile.path);
- febeZipFile.append(FEBEWINZIPFILENAME);
- febeUnZipFile.append(FEBEWINUNZIPFILENAME);
- break;
- case 2: // *nix
- febeNLchar = "\n"; // Linux LF
- febeSetUnicharPref("extensions.febe.nixpathzip",febeZipFile.path);
- febeSetUnicharPref("extensions.febe.nixpathunzip",febeUnZipFile.path);
- febePrefs.setBoolPref("extensions.febe.chmodok",false);
- febeZipFile.append(FEBENIXZIPFILENAME);
- febeUnZipFile.append(FEBENIXUNZIPFILENAME);
- var isOk = (febeUnZipFile.isExecutable() && febeZipFile.isExecutable());
- if(!isOk){
- febeChmodWindow();
- if(febePrefs.getBoolPref("extensions.febe.chmodok") == false){return false;}
- }//if
- break;
- case 3: // Mac
- febeNLchar = "\n"; // Mac LF
- febeSetUnicharPref("extensions.febe.macpathzip",febeZipFile.path);
- febeSetUnicharPref("extensions.febe.macpathunzip",febeUnZipFile.path);
- febePrefs.setBoolPref("extensions.febe.chmodok",false);
- febeZipFile.append(FEBEMACZIPFILENAME);
- febeUnZipFile.append(FEBEMACUNZIPFILENAME);
- var isOk = (febeUnZipFile.isExecutable() && febeZipFile.isExecutable());
- if(!isOk){
- febeChmodWindow();
- if(febePrefs.getBoolPref("extensions.febe.chmodok") == false){return false;}
- }//if
- break;
- }//switch
-
- febeCopyZips();
-
- if(febeInitialized == true){return true;} // Only run the rest of this routine once
- febeInitialized = true;
-
- // Create a log file in the temporary directory
- var logFile = febeTmpDir.clone();
- logFile.append("febe.log");
- logFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0755);
-
- // Get the batch sequence number. ex: "febe-8.log", febeBuSeq = "-8"
- var tmp = logFile.leafName;
- febeBuSeq = "";
- var p1 = tmp.indexOf("-");
- if (p1 != -1){
- var p2 = tmp.indexOf(".log");
- febeBuSeq = tmp.slice(p1,p2);
- }//if
- logFile.remove(false);
-
- // Create pointer to profile directory
- febeProfDir = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);
-
- // Get profile name
- var tmp = "";
- for (i = febeProfDir.path.length; i > 0; i--){
- var c = febeProfDir.path.charAt(i);
- var delimiter = "\\"
- if(febePlatform == 2){delimiter = "/";} // *nix
- if(febePlatform == 3){delimiter = "/";} // Mac
- if( c == delimiter ){
- break;
- }else{
- tmp = c + tmp;
- }
- }//for
- var p = tmp.indexOf(".")
- febeProfName = tmp.substr(p+1);
- //febeProfName = febeDosHappy(febeProfName);
-
- // Get pointer to background script runner
- FEBEbg = FEBEdir.clone();
- if(febePlatform == 1){ // Windows
- FEBEbg.append("FEBEbg.exe");
- }else{
- //FEBEbg = "/bin/sh";
- }//if
- return true;
- }//febeInitDir()
-
- function febeChmodWindow(){
- if(!febeDisablePermChk){
- return openDialog("chrome://febe/content/febeChmod.xul", "FEBE", "chrome,modal,resizable");
- }else{
- febePrefs.setBoolPref("extensions.febe.chmodok",true);
- return true;
- }//if
- }//febeChmodWindow()
-
- function febeClearDir(){
- // Clear destination directory
- if(febeClearDestDir == false){return true;}
- var entries = febeBuDesDir.directoryEntries;
- var numFiles = 0;
- var numDirs = 0;
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- if(entry.isFile()){numFiles++;}
- if(entry.isDirectory()){numDirs++;}
- }//while
-
- // Warn before delete?
- var clearWarning = new Boolean(false);
- var prefName = "extensions.febe.clearwarning";
- if(febePrefs.prefHasUserValue(prefName)){
- clearWarning = febePrefs.getBoolPref(prefName);
- } else {
- febePrefs.setBoolPref(prefName,true);
- clearWarning = false;
- }//if
-
- if((clearWarning) && numFiles != 0){
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- var checkResult = {};
-
- var x1 = new RegExp("x1");
- var x2 = new RegExp("x2");
- var tmp = febeMsg[99];
- tmp = tmp.replace(x1,numFiles);
- tmp = tmp.replace(x2,numDirs);
- tmp += "\n"+febeMsg[100];
-
- //var OK = promptService.confirm(window,febeMsg[98],tmp)
- var OK = febeConfirm(tmp);
- if(!OK){return false;}
- }//if
-
- var entries = febeBuDesDir.directoryEntries;
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- if(entry.isFile()){entry.remove(false);}
- }//while
- return true;
- }//febeClearDir()
-
- function febeSetExDir(){ // Get/show the path to the executables
- febePlatform = febeGetPlatform();
- if(febePlatform == 1){
- document.getElementById("febeZipValue").value = FEBEWINZIPFILENAME;
- document.getElementById("febeUnzipValue").value = FEBEWINUNZIPFILENAME;
- document.getElementById("febeExtDirZip").value = febePrefs.getCharPref("extensions.febe.winpathzip");
- }//if
- if(febePlatform == 2){
- document.getElementById("febeZipValue").value = FEBENIXZIPFILENAME;
- document.getElementById("febeUnzipValue").value = FEBENIXUNZIPFILENAME;
- document.getElementById("febeExtDirZip").value = febePrefs.getCharPref("extensions.febe.nixpathzip");
- }//if
- if(febePlatform == 3){
- document.getElementById("febeZipValue").value = FEBEMACZIPFILENAME;
- document.getElementById("febeUnzipValue").value = FEBEMACUNZIPFILENAME;
- document.getElementById("febeExtDirZip").value = febePrefs.getCharPref("extensions.febe.macpathzip");
- }//if
- return true;
- }//febeSetExDir()
-
- function febeChmod(){
- febePlatform = febeGetPlatform();
- if(febePlatform == 1){return};
- // Try to change permissions
- if (febePlatform == 2) {
- var febeZipExecutable = FEBENIXZIPFILENAME;
- var febeUnZipExecutable = FEBENIXUNZIPFILENAME;
- var febeZipExecutablePath = febePrefs.getCharPref("extensions.febe.nixpathzip");
- febeZipExecutablePath += "/"+ febeZipExecutable;
- var febeUnZipExecutablePath = febePrefs.getCharPref("extensions.febe.nixpathunzip");
- febeUnZipExecutablePath += "/"+ febeUnZipExecutable;
- }else{
- var febeZipExecutable = FEBEMACZIPFILENAME;
- var febeUnZipExecutable = FEBEMACUNZIPFILENAME;
- var febeZipExecutablePath = febePrefs.getCharPref("extensions.febe.macpathzip");
- febeZipExecutablePath += "/"+ febeZipExecutable;
- var febeUnZipExecutablePath = febePrefs.getCharPref("extensions.febe.macpathunzip");
- febeUnZipExecutablePath += "/"+ febeUnZipExecutable;
- }//if
-
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath("/");
- file.append("bin");
- file.append("chmod");
- var process = Components.classes["@mozilla.org/process/util;1"]
- .createInstance(Components.interfaces.nsIProcess);
- process.init(file);
-
- var argv = ["0755",febeZipExecutablePath,febeUnZipExecutablePath];
-
- process.run(true, argv, argv.length);
-
- FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
- .getService(Components.interfaces.nsIExtensionManager)
- .getInstallLocation(FEBE_GUID)
- .getItemLocation(FEBE_GUID);
- febeZipFile = FEBEdir.clone();
- febeUnZipFile = FEBEdir.clone();
- febeZipFile.append(febeZipExecutable);
- febeUnZipFile.append(febeUnZipExecutable);
-
- var isOk = (febeUnZipFile.isExecutable() && febeZipFile.isExecutable());
- if(isOk == true){
- febeAlert(febeMsg[104]);
- febePrefs.setBoolPref("extensions.febe.chmodok",true);
- return true;
- }else{
- var style = "<style>color: red;font-size: 12pt;</style>";
- var tmp = style+febeMsg[105]+"\n\n";
- style = "<style>color: black;font-size: 10pt;</style>";
- tmp += style+febeMsg[177]+"\n";
- tmp += style+febeMsg[178]+"\n";
- febeAlert(tmp);
- febePrefs.setBoolPref("extensions.febe.chmodok",false);
- return false;
- }//if
- }//febeChmod()
-
- function febeDosHappy(aString){
- // Mask out DOS incompatable characters
- if(febePlatform != 1){return aString;}
- var goodList = " .@-_";
- goodList += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- goodList += "abcdefghijklmnopqrstuvwxyz";
- goodList += "0123456789";
- for (var i = 0; i < aString.length; i++){
- var c = aString.charAt(i);
- var OK = new Boolean(false);
- for (var j = 0; j < goodList.length; j++){
- var tChar = goodList.charAt(j);
- //print(c+" : "+tChar+" : "+OK)
- if(c == tChar){
- OK = true;
- break;
- }//if
- }//for
- if(OK == false){aString = aString.replace(c,"_");}
- }//for
- return aString;
- }//febeDosHappy
-
- function febeExtInfo(extGuid){
-
- // Get extension info from extensions.rdf
-
- var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"]
- .getService(Components.interfaces.nsIRDFService);
-
- var profileDir = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);
- profileDir.append("extensions.rdf");
-
- // Fix for international characters
- var ioServ = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var fph = ioServ.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
- var srcFile = fph.getURLSpecFromFile(profileDir);
-
- var ds = rdfs.GetDataSourceBlocking(srcFile);
-
- // Use old method if something comes up undefined
- var em = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
- var ext = null;
- if (em.getItemForID){
- ext = em.getItemForID(extGuid);
- }else{
- ext = em.getItemList(extGuid, null, {})[0];
- }//if
-
- var subject = rdfs.GetResource("urn:mozilla:item:"+extGuid);
- var prefix = "http://www.mozilla.org/2004/em-rdf#";
-
- // Guid
- this.guid = extGuid;
-
- // Name
- var predicate = rdfs.GetResource(prefix + "name");
- var name = ds.GetTarget(subject, predicate, true);
- if(name){
- this.name = name.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
- }else{
- this.name = ext.name;
- }//if
- if(!this.name){this.name="(none)";}
-
- // Version
- var predicate = rdfs.GetResource(prefix + "version");
- var version = ds.GetTarget(subject, predicate, true);
- if(version){
- this.version = version.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
- }else{
- this.version = ext.version;
- }//if
- if(!this.version){this.version="(none)";}
-
- // Description
- var predicate = rdfs.GetResource(prefix + "description");
- var description = ds.GetTarget(subject, predicate, true);
- if(description){this.description = description.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.description){this.description="(none)";}
-
- // Home Page URL
- var predicate = rdfs.GetResource(prefix + "homepageURL");
- var homepageURL = ds.GetTarget(subject, predicate, true);
- if(homepageURL){this.homepageURL = homepageURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.homepageURL){this.homepageURL="";}
-
- // Creator
- var predicate = rdfs.GetResource(prefix + "creator");
- var creator = ds.GetTarget(subject, predicate, true);
- if(creator){this.creator = creator.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.creator){this.creator="(none)";}
-
- // Disabled?
- var predicate = rdfs.GetResource(prefix + "userDisabled");
- var userDisabled = ds.GetTarget(subject, predicate, true);
- if(userDisabled){
- this.isDisabled = userDisabled.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
- }else{
- this.isDisabled = false;
- }//if
-
- // iconURL
- var predicate = rdfs.GetResource(prefix + "iconURL");
- var iconURL = ds.GetTarget(subject, predicate, true);
- if(iconURL){
- this.iconURL = iconURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
- }else{
- this.iconURL = ext.iconURL;
- }//if
- if(!this.iconURL){this.iconURL="chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";}
-
- // minVersion
- this.minVersion = ext.minAppVersion;
- if(!this.minVersion){this.minVersion="(none)";}
-
- // maxVersion
- this.maxVersion = ext.maxAppVersion;
- if(!this.maxVersion){this.maxVersion="(none)";}
-
- // installLocation
- var predicate = rdfs.GetResource(prefix + "installLocation");
- var installLocation = ds.GetTarget(subject, predicate, true);
- if(installLocation){this.installLocation = installLocation.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.installLocation){this.installLocation="(none)";}
-
- // parseType
- var predicate = rdfs.GetResource(prefix + "type");
- var parseType = ds.GetTarget(subject, predicate, true);
- if(parseType){
- this.type = parseType.QueryInterface(Components.interfaces.nsIRDFInt).Value;
- }else{
- this.type = ext.type;
- }//if
-
- // internalName
- var predicate = rdfs.GetResource(prefix + "internalName");
- var internalName = ds.GetTarget(subject, predicate, true);
- if(internalName){this.internalName = internalName.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.internalName){this.internalName="(none)";}
-
- // updateURL
- var predicate = rdfs.GetResource(prefix + "updateURL");
- var updateURL = ds.GetTarget(subject, predicate, true);
- if(updateURL){this.updateURL = updateURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.updateURL){this.updateURL="(none)";}
-
- // optionsURL
- var predicate = rdfs.GetResource(prefix + "optionsURL");
- var optionsURL = ds.GetTarget(subject, predicate, true);
- if(optionsURL){this.optionsURL = optionsURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.optionsURL){this.optionsURL="(none)";}
-
- // aboutURL
- var predicate = rdfs.GetResource(prefix + "aboutURL");
- var aboutURL = ds.GetTarget(subject, predicate, true);
- if(aboutURL){this.aboutURL = aboutURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.aboutURL){this.aboutURL="(none)";}
-
- // availableUpdateURL
- var predicate = rdfs.GetResource(prefix + "availableUpdateURL");
- var availableUpdateURL = ds.GetTarget(subject, predicate, true);
- if(availableUpdateURL){this.availableUpdateURL = availableUpdateURL.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.availableUpdateURL){this.availableUpdateURL="(none)";}
-
- // availableUpdateHash
- var predicate = rdfs.GetResource(prefix + "availableUpdateHash");
- var availableUpdateHash = ds.GetTarget(subject, predicate, true);
- if(availableUpdateHash){this.availableUpdateHash = availableUpdateHash.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.availableUpdateHash){this.availableUpdateHash="(none)";}
-
- // availableUpdateVersion
- var predicate = rdfs.GetResource(prefix + "availableUpdateVersion");
- var availableUpdateVersion = ds.GetTarget(subject, predicate, true);
- if(availableUpdateVersion){this.availableUpdateVersion = availableUpdateVersion.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;}
- if(!this.availableUpdateVersion){this.availableUpdateVersion="(none)";}
-
- // contributors
- var predicate = rdfs.GetResource(prefix + "contributor");
- var targets = ds.GetTargets(subject, predicate, true);
- var contributors = [];
- if(targets){
- while (targets.hasMoreElements()){
- var contributor = targets.getNext();
- if (contributor instanceof Components.interfaces.nsIRDFLiteral){
- contributors.push(contributor.Value);
- }//if
- }//while
- this.contributors = contributors;
- }//if
- return true;
- }//febeExtInfo()
-
- function febeOpenLink(URL){
- // Thanks to menet for providing the code to display the results page in an unused tab
- // if one is availble.
- if(!URL){return true;}
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- var febeGetBrowser = win.getBrowser();
- var currBlank = (febeGetBrowser &&
- (febeGetBrowser.mCurrentTab.linkedBrowser &&
- (febeGetBrowser.mCurrentTab.linkedBrowser.contentDocument.location == "about:blank")) ||
- (!febeGetBrowser.mCurrentTab.linkedBrowser &&
- (febeGetBrowser.mCurrentTab.label == "(Untitled)")));
- if (currBlank)
- {
- var resultsWindow = win.loadURI(URL);
- } else {
- var resultsWindow = win.openNewTabWith(URL, this.docURL, null, null);
- }//if
- return true;
- }febeOpenLink()
-
- function febeRestoreProgress(){
- febeGetPrefs();
- if(febeDispProgress == true){
- // Open the progress window
- febeWin = openDialog("chrome://febe/content/febeRestore.xul", "FEBE", "chrome,dependent,alwaysRaised,centerscreen,dialog='no'");
- febeWin.focus();
- // Give the browser a chance to display the progress window before the restore starts
- febePause(1000);
- }//if
- return true;
- }//febeRestoreProgress()
-
- // ------------------ Backup Functions --------------------
-
- function febeBackupExtensions(){
- // Backup extensions and themes
-
- var extDir = febeProfDir.clone();
- extDir.append("extensions");
- var entries = extDir.directoryEntries;
-
- febeExtensionsList = {};
- febeThemesList = {};
- febeErrorList = [];
- febeWarningList = [];
- febeDisabledCount = 0;
- febeExtensionsList["**total**"] = 0; // Associative arrays don't have a
- febeThemesList["**total**"] = 0; // 'length' property ... So keep count
-
- if(buExtensions == false && buThemes == false){return true;}
-
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- if(!entry.isDirectory()){continue;} // Don't process junk in the extension directory
- extGUID = entry.leafName;
-
- // Get info for item
- var thisExt = new febeExtInfo(extGUID);
- var eType = thisExt.type; // 2=Extension, 4=Theme
- if(eType != 2 && eType != 4){continue;} // Not an extension or theme ... what is it?
-
- if(eType == 2 && buExtensions == false){
- continue; // Not backing up extensions at this time
- }else{
- exBackedUp = true;
- }//if
- if(eType == 4 && buThemes == false){
- continue; // Not backing up themes at this time
- }else{
- thBackedUp = true;
- }//if
-
- var extIsDisabled = thisExt.isDisabled;
- if(ignoreDisabled == true){
- if(extIsDisabled != false){
- febeDisabledCount++;
- continue;
- }//if
- }//if
- var extName = thisExt.name;
- var extVer = febeStripSpaces(thisExt.version);
- var extIcon = thisExt.iconURL;
- if(extIsDisabled){extIcon = "chrome://febe/skin/disabled.png";}
- var extHome = thisExt.homepageURL;
-
- var batchFileName = febeStripSpaces(extName)+"{" + extVer + "}";
- febeExtExt = ".xpi";
- if(eType == 4){febeExtExt = ".jar"};
- var extBuName = batchFileName+febeExtExt;
- var srcName = extDir.clone();
- srcName.append(extGUID);
- srcName = srcName.path;
- febeDestDir = febeTmpDir.clone();
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- febeSubRootDir = extGUID;
- febeDirCopy(extDir.path);
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEzip.exe\"");
- batchlines.push("SET SRCDIR="+"\""+extGUID+"\"");
- batchlines.push("SET SRCNAME="+"*");
- batchlines.push("SET DEST=\"..\\"+extBuName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("CD %SRCDIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+extBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
-
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+extBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
-
- var item = new febeExtObj;
- item.Name = batchFileName;
- item.Path = "";
- item.Icon = extIcon;
- item.Home = extHome;
- item.guid = extGUID;
-
- if (febeGoBatch(batchFileName,batchlines)){
-
- if(febePlatform == 1){ // Copy the backup to the destination directory
- febeCopyFile(febeTmpDir.path+"\\"+extBuName,febeExBuDir,extBuName);
- }//if
-
- item.verified = febeVerify(extBuName);
- }else{
- item.verified = false;
- }//if
-
- if(eType == 2){
- febeExtensionsList[item.Name] = item;
- febeExtensionsList["**total**"]++;
- }
- if(eType == 4){
- febeThemesList[item.Name] = item;
- febeThemesList["**total**"]++;
- }
- }//while
- return true;
- }//febeBackupExtensions()
-
- function febeBackupBookmarks(){
- bmBackedUp = false;
- if (!buBookmarks){return true;}
- var profileDir = febeProfDir.clone();
- profileDir.append("bookmarks.html");
- var srcFile = profileDir.path
- bmBuName ="bookmarks{" + febeProfName + "}.html";
- if (febeCopyFile(srcFile,febeExBuDir,bmBuName)){bmBackedUp = febeVerify(bmBuName);}
- return true;
- }//febeBackupBookmarks()
-
- function febeBackupPreferences(){
- prBackedUp = false;
- if (!buPreferences){return true;}
- var profileDir = febeProfDir.clone();
- profileDir.append("prefs.js");
- var srcFile = profileDir.path
- prBuName ="prefs{" + febeProfName + "}.js";
- if (febeCopyFile(srcFile,febeExBuDir,prBuName)){prBackedUp = febeVerify(prBuName);}
- return true;
- }//febeBackupPreferences()
-
- function febeBackupCookies(){
- ckBackedUp = false;
- if (!buCookies){return true;}
- var profileDir = febeProfDir.clone();
- profileDir.append("cookies.txt");
- var srcFile = profileDir.path
- ckBuName ="cookies{" + febeProfName + "}.txt";
- if (febeCopyFile(srcFile,febeExBuDir,ckBuName)){ckBackedUp = febeVerify(ckBuName);}
- return true;
- }//febeBackupCookies()
-
- function febeBackupUserChrome(){
- chBackedUp = false;
- if (!buUserChrome){return true;}
- // Get pointer to userChrome.css
- var profileDir = febeProfDir.clone();
- profileDir.append("chrome");
- profileDir.append("userChrome.css");
- if (!profileDir.exists()){return true;}
- var srcFile = profileDir.path;
- chBuName ="userChrome{" + febeProfName + "}.css";
- if (febeCopyFile(srcFile,febeExBuDir,chBuName)){chBackedUp = febeVerify(chBuName);}
- return true;
- }//febeBackupUserChrome()
-
- function febeBackupUserContent(){
- ucBackedUp = false;
- if (!buUserContent){return true;}
- // Get pointer to userChrome.css
- var profileDir = febeProfDir.clone();
- profileDir.append("chrome");
- profileDir.append("userContent.css");
- if (!profileDir.exists()){return true;}
- var srcFile = profileDir.path;
- ucBuName ="userContent{" + febeProfName + "}.css";
- if (febeCopyFile(srcFile,febeExBuDir,ucBuName)){ucBackedUp = febeVerify(ucBuName);}
- return true;
- }//febeBackupUserContent()
-
- function febeBackupPasswords(){
- pwBackedUp = false;
- if (!buUserPwd){return true;}
-
- febeExtExt=".fbu"
- var batchFileName = "usernames-passwords{" + febeDosHappy(febeProfName) + "}";
- pwBuName = batchFileName + febeExtExt;
-
-
- var srcName = febeProfDir.clone();
- srcName = srcName.path;
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the files to the tmp directory
- febeIgnoreError = true; // Don't worry if signons.txt doesn't exist
- febeCopyFile(febeProfDir.path+"\\signons.txt",febeTmpDir.path,"signons.txt");
- febeIgnoreError = true;
- febeCopyFile(febeProfDir.path+"\\signons2.txt",febeTmpDir.path,"signons2.txt");// Fix for FX 2.0.0.2
- febeCopyFile(febeProfDir.path+"\\key3.db",febeTmpDir.path,"key3.db");
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET ZFILE=FEBEzip.exe");
- batchlines.push("SET SRCNAME=signons*.txt key3.db");
- batchlines.push("SET DEST="+"\""+pwBuName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
-
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+pwBuName+"\"");
- batchlines.push("SRCNAME=\"signons*.txt key3.db\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("export SRCNAME");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" $SRCNAME`");
- }//if
-
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+pwBuName+"\"");
- batchlines.push("SRCNAME=\"signons*.txt key3.db\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("export SRCNAME");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" $SRCNAME`");
- }//if
-
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){febeCopyFile(febeTmpDir.path+"\\"+pwBuName,febeExBuDir,pwBuName);}
- pwBackedUp = febeVerify(pwBuName);
- }//if
- return true;
- }//febeBackupPasswords()
-
- function febeBackupPhishingData(){
- pdBackedUp = false;
- if (!buPhishingData){return true;}
-
- febeExtExt=".fbu"
- var batchFileName = "phishing-data{" + febeDosHappy(febeProfName) + "}";
- pdBuName = batchFileName + febeExtExt;
-
-
- var srcName = febeProfDir.clone();
- srcName = srcName.path;
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the files to the tmp directory
- febeCopyFile(febeProfDir.path+"\\kf.txt",febeTmpDir.path,"kf.txt");
- febeCopyFile(febeProfDir.path+"\\urlclassifier2.sqlite",febeTmpDir.path,"urlclassifier2.sqlite");
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET ZFILE=FEBEzip.exe");
- batchlines.push("SET SRCNAME=kf.txt urlclassifier2.sqlite");
- batchlines.push("SET DEST="+"\""+pdBuName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
-
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+pdBuName+"\"");
- batchlines.push("SRCNAME=\"kf.txt urlclassifier2.sqlite\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("export SRCNAME");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" $SRCNAME`");
- }//if
-
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+pdBuName+"\"");
- batchlines.push("SRCNAME=\"kf.txt urlclassifier2.sqlite\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("export SRCNAME");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" $SRCNAME`");
- }//if
-
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){febeCopyFile(febeTmpDir.path+"\\"+pdBuName,febeExBuDir,pdBuName);}
- pdBackedUp = febeVerify(pdBuName);
- }//if
- return true;
- }//febeBackupPhishingData()
-
- function febeBackupSearchPlugins(){
- spBackedUp = false;
- if (!buSearchPlugins){return true;}
-
- // See if search plugins exist
- var profileDir = febeProfDir.clone();
- profileDir.append("searchPlugins");
- if (!(profileDir.exists() && profileDir.isDirectory())){return true;}
-
- febeExtExt=".fbu"
- var batchFileName = "searchPlugins{" + febeDosHappy(febeProfName) + "}";
- spBuName = batchFileName + febeExtExt;
-
- var srcName = febeProfDir.clone();
- srcName.append("searchPlugins");
- srcName = srcName.path;
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
-
- // Copy the files to the tmp directory
- batchFileName = "searchPlugins";
- febeSubRootDir = batchFileName;
- febeDestDir = febeTmpDir.clone();
- febeDirCopy(srcName);
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEzip.exe\"");
- batchlines.push("SET SRCNAME=*");
- batchlines.push("SET DEST=\"..\\"+batchFileName+".fbu"+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+spBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+spBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
-
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){febeCopyFile(febeTmpDir.path+"\\"+batchFileName+".fbu",febeExBuDir,spBuName);}
- spBackedUp = febeVerify(spBuName);
- }//if
- return true;
- }//febeBackupSearchPlugins()
-
- function febeBackupBrowserHistory(){
- hsBackedUp = false;
- if (!buBrowserHistory){return true;}
- // Get pointer to history.dat
- var profileDir = febeProfDir.clone();
- profileDir.append("history.dat");
- if (!profileDir.exists()){return true;}
- var srcFile = profileDir.path;
- hsBuName ="history{" + febeProfName + "}.dat";
- if (febeCopyFile(srcFile,febeExBuDir,hsBuName)){hsBackedUp = febeVerify(hsBuName);}
- return true;
- }//febeBackupBrowserHistory()
-
- function febeBackupFormFillHistory(){
- ffBackedUp = false;
- if (!buFormFillHistory){return true;}
- // Get pointer to formhistory.dat
- var profileDir = febeProfDir.clone();
- profileDir.append("formhistory.dat");
- if (!profileDir.exists()){return true;}
- var srcFile = profileDir.path;
- ffBuName ="formhistory{" + febeProfName + "}.dat";
- if (febeCopyFile(srcFile,febeExBuDir,ffBuName)){ffBackedUp = febeVerify(ffBuName);}
- return true;
- }//febeBackupFormFillHistory()
-
- function febeBackupPermissions(){
- pmBackedUp = false;
- if (!buPermissions){return true;}
- var profileDir = febeProfDir.clone();
- profileDir.append("hostperm.1");
- var srcFile = profileDir.path
- pmBuName ="hostperm{" + febeProfName + "}.1";
- if (febeCopyFile(srcFile,febeExBuDir,pmBuName)){pmBackedUp = febeVerify(pmBuName);}
- return true;
- }//febeBackupPermissions()
-
- function febeBackupUDBu(){
- if (!buUDBu){return true;}
- febeUDBuInit();
- udBackedUp = 0;
- febeUDBuDone = [];
- for(var i in febeUDBuList){
- var Label = new String(febeUDBuList[i].Label);
- if(Label.length == 0){continue;} // Datafile is empty?
- var Type = new Number(febeUDBuList[i].Type);
- var Description = new String(febeUDBuList[i].Description);
- var Path = new String(febeUDBuList[i].Path);
- var Include = new Boolean(false);
- Include = febeUDBuList[i].Include;
- var item = new febeUDBuDoneObj;
- item.Description = Description;
- item.Type = Type; // Not really needed ... just for completeness
- if(Include == "false"){continue;}
- if(Type == 1){ // Folder
- febeExtExt=".fbu"
- var batchFileName = Label+"{" + febeDosHappy(febeProfName) + "}";
- udBuName = batchFileName + febeExtExt;
- var srcName = Path;
- var batchlines = [];
- item.Name = udBuName;
- if(febePlatform == 1){ // Window
- // Copy the files to the tmp directory
- var batchFileName = "UDBU"+"{" + febeDosHappy(febeProfName) + "}";
- batchFileName = febeUnique(febeTmpDir,batchFileName);
- febeSubRootDir = febeLeafname(srcName);
- var destName = batchFileName+".fbu";
- febeDestDir = febeTmpDir.clone();
- febeDirCopy(febeParent(srcName));
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+febeSubRootDir+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEzip.exe\"");
- batchlines.push("SET SRCNAME=*");
- batchlines.push("SET DEST=\"..\\"+destName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+udBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+udBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){febeCopyFile(febeTmpDir.path+"\\"+destName,febeExBuDir,udBuName);}
- if(febeVerify(udBuName)){
- udBackedUp++;
- }else{
- item.Description = "*** Error backing up "+Description;
- }//if
- }//if
-
- febeUDBuDone[Label] = item;
-
- }else{ // File
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- file.initWithPath(Path);
- var UDBuName = Label+"{"+febeProfName+"}-"+file.leafName;
- item.Name = UDBuName;
-
- if(file.exists()){
- febeCopyFile(Path,febeExBuDir,UDBuName);
- }else{
- var style = "<style>color: red;font-size: 12pt;</style>";
- var tmp = style+febeMsg[166].replace("%path%",Path)+"\n"
- febeAlert(tmp);
- }//if
-
- if(febeVerify(UDBuName)){
- udBackedUp++;
- }else{
- item.Description = febeMsg[167].replace("%description%",Description);
- }//if
- febeUDBuDone[Label] = item;
- }//if
- }//for
- return true;
- }//febeBackupUDbu()
-
- function febeBackupProfile(){
- upBackedUp = false;
- febeExtensionsList = [];
- febeThemesList = [];
- febeExtensionsList["**total**"] = 0; // Associative arrays don't have a
- febeThemesList["**total**"] = 0; // 'length' property ... So keep count
-
- if (!buProfile){return true;}
-
- febeExtExt=".fbu"
- var batchFileName = "profile{" + febeProfName + "}";
- upBuName = batchFileName + febeExtExt;
-
- var srcName = febeProfDir.clone();
- srcName = srcName.path;
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the files to the tmp directory
- var profile = febeProfDir.clone();
- febeSubRootDir = profile.leafName;
- srcName = profile.parent.path;
- batchFileName = "profile";
-
- febeDestDir = febeTmpDir.clone();
- febeDirCopy(srcName);
-
- // Rename the profile backup
- try{
- // Delete old backup file
- var oldProfile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- oldProfile.initWithPath(febeDestDir.path);
- oldProfile.append(batchFileName);
- if (oldProfile.exists()){
- oldProfile.remove(true);
- }//if
- var filespec = Components.classes["@mozilla.org/filespec;1"].createInstance(Components.interfaces.nsIFileSpec);
- filespec.nativePath = febeDestDir.path+"\\"+febeSubRootDir;
- filespec.rename(batchFileName);
- }catch(e){
- var msg = febeMsg[162]+"\n";
- msg += febeDestDir.path+'\\'+febeSubRootDir+'" to "'+batchFileName+'"';
- febeFatal(e,msg);
- return false;
- }
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEzip.exe\"");
- batchlines.push("SET SRCNAME=*");
- batchlines.push("SET DEST=\"..\\"+batchFileName+".fbu"+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -rv %DEST% %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+upBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCDIR="+"\""+srcName+"\"");
- batchlines.push("DEST="+"\""+febeExBuDir+"/"+upBuName+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export DEST");
- batchlines.push("export SRCDIR");
- batchlines.push("cd \"$SRCDIR\"");
- batchlines.push("`\"$ZFILE\" -rv \"$DEST\" *`");
- }//if
-
- if (febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- febeCopyFile(febeTmpDir.path+"\\"+batchFileName+".fbu",febeExBuDir,upBuName);}
- upBackedUp = febeVerify(upBuName);
- }//if
- return true;
- }//febeBackupProfile()
-
- // ------------------ End of Backup Functions -------------
-
- // ------------------ Restore Functions -------------------
-
- function febeRestoreExtensions(){
- if(!febeInitDir()){return false;}
- febePickFiles("*.xpi",25);
-
- var xpi = new Array();
- for (var i = 0; i < febeETinstall.length; i++){
- var tmp = "file:///" + febeETinstall[i].Path;
- var name = febeETinstall[i].Name;
- xpi[name]=tmp;
- }//for
- InstallTrigger.install(xpi);
- return true;
- }//febeRestoreExtensions()
-
- function febeRestoreThemes(){
- if(!febeInitDir()){return false;}
- febePickFiles("*.jar",24);
-
- var jar = new Array();
- for (var i = 0; i < febeETinstall.length; i++){
- var tmp = "file:///" + febeETinstall[i].Path;
- var name = febeETinstall[i].Name;
- jar[name]=tmp;
- }//for
- InstallTrigger.install(jar);
- return true;
- }//febeRestoreThemes()
-
- function febeRestoreBookmarks(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("bookmarks*.html",33)){return true};
-
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(37,febeBUdate)){
- febePrefs.setBoolPref("extensions.febe.restoreBookmarks",true);
- febePrefs.setCharPref("extensions.febe.restBkmrks.srcName",febePathName);
- febeAlert(febeMsg[50]);
- febeRestartFx();
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreBookmarks()
-
- function febeRestoreBookmarksFinish(){
- febeSetMsgs();
- if(!febeInitDir()){return false;}
- var OK = new Boolean(true);
- try{
- var febePathName = febePrefs.getCharPref("extensions.febe.restBkmrks.srcName");
- febeCopyFile(febePathName,febeProfDir.path,"bookmarks.html");
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){febeAlert(febeMsg[42])};
- febePrefs.setBoolPref("extensions.febe.restoreBookmarks",false);
- return true;
- }//febeRestoreBookmarksFinish
-
- function febeRestorePreferences(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("prefs*.js",34)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(38,febeBUdate)){
-
- // Pointer to preferences
- var oldPrefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
-
- // Pointer to new (restored) preferences
- var newPrefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
-
- // Pointer to backed up preferences file
- var newPrefFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
-
- // Get pointer to "Prefs.js"
- var PrefsFile = febeProfDir.clone();
-
- PrefsFile.append("prefs.js")
- newPrefFile.initWithPath(febePathName); // Initialize backed up prefs file
- oldPrefs.deleteBranch(""); // Delete old preferences
- newPrefs.readUserPrefs(newPrefFile); // Read in backed up preferences
- newPrefs.savePrefFile(PrefsFile); // Save the restored preferences file
- febeAlert(febeMsg[43]);
- febeRestartFx(); // Restart Firefox
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestorePreferences()
-
- function febeRestoreCookies(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("cookies*.txt",35)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(39,febeBUdate)){
- febeCopyFile(febePathName,febeProfDir.path,"cookies.txt");
- febeAlert(febeMsg[44]);
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreCookies()
-
- function febeRestoreUserChrome(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- var chromeDir = febeProfDir.clone();
- chromeDir.append("chrome");
- if(!febePickFile("userChrome*.css",78)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(68,febeBUdate)){
- febeCopyFile(febePathName,chromeDir.path,"userChrome.css");
- febeAlert(febeMsg[79]);
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreUserChrome()
-
- function febeRestoreUserContent(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- var contentDir = febeProfDir.clone();
- contentDir.append("chrome");
- if(!febePickFile("userContent*.css",92)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(69,febeBUdate)){
- febeCopyFile(febePathName,contentDir.path,"userContent.css");
- febeAlert(febeMsg[93]);
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreUserContent()
-
- function febeRestorePasswords(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("usernames-passwords*.fbu",80)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(70,febeBUdate)){
- febePrefs.setBoolPref("extensions.febe.restorePasswords",true);
- febePrefs.setCharPref("extensions.febe.restPwd.srcName",febePathName);
- febeAlert(febeMsg[94]);
- febeRestartFx();
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestorePasswords()
-
- function febeRestorePasswordsFinish(){
- febeSetMsgs();
- if(!febeInitDir()){return false;}
- var OK = new Boolean(true);
- try{
- var srcName = febePrefs.getCharPref("extensions.febe.restPwd.srcName");
- var tmpRestName = "usernames-passwords.fbu";
- var batchFileName = "restorePasswords";
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
-
- // Copy the archive to the tmp directory
- febeCopyFile(srcName,febeTmpDir.path,tmpRestName);
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEunzip.exe\"");
- batchlines.push("SET SRCNAME=\"..\\"+tmpRestName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("RD /S /Q %TMP2DIR%");
- batchlines.push("MD %TMP2DIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -o %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+srcName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+srcName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
-
- if(febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- srcName=febeTmpDir.path+"\\"+batchFileName+"\\signons.txt";
- febeIgnoreError = true; // Don't worry if signons.txt doesn't exist
- febeCopyFile(srcName,febeProfDir.path,"signons.txt");
- srcName=febeTmpDir.path+"\\"+batchFileName+"\\signons2.txt";
- febeIgnoreError = true;
- febeCopyFile(srcName,febeProfDir.path,"signons2.txt");
- srcName=febeTmpDir.path+"\\"+batchFileName+"\\key3.db";
- febeCopyFile(srcName,febeProfDir.path,"key3.db");
- }//if
- }else{
- throw febeMsg[95];
- }//if
-
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){febeAlert(febeMsg[81])};
- febePrefs.setBoolPref("extensions.febe.restorePasswords",false);
- return true;
- }//febeRestorePasswordsFinish
-
- function febeRestorePhishingData(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("phishing-data*.fbu",82)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(71,febeBUdate)){
- febePrefs.setBoolPref("extensions.febe.restorePhishingData",true);
- febePrefs.setCharPref("extensions.febe.restPhishingData.srcName",febePathName);
- febeAlert(febeMsg[96]);
- febeRestartFx();
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreCertificates()
-
- function febeRestorePhishingDataFinish(){
- febeSetMsgs();
- if(!febeInitDir()){return false;}
- var OK = new Boolean(true);
- try{
- var srcName = febePrefs.getCharPref("extensions.febe.restPhishingData.srcName");
- var tmpRestName = "phishing-data.fbu";
- var batchFileName = "restorePhishingData";
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the archive to the tmp directory
- febeCopyFile(srcName,febeTmpDir.path,tmpRestName);
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEunzip.exe\"");
- batchlines.push("SET SRCNAME=\"..\\"+tmpRestName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("RD /S /Q %TMP2DIR%");
- batchlines.push("MD %TMP2DIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -o %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+srcName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+srcName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
-
- if(febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- srcName=febeTmpDir.path+"\\"+batchFileName+"\\kf.txt";
- if(!febeCopyFile(srcName,febeProfDir.path,"kf.txt")){throw febeMsg[103];}
- srcName=febeTmpDir.path+"\\"+batchFileName+"\\urlclassifier2.sqlite";
- if(!febeCopyFile(srcName,febeProfDir.path,"urlclassifier2.sqlite")){throw febeMsg[103];}
- }//if
- }else{
- throw febeMsg[103];
- }//if
-
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){febeAlert(febeMsg[83])};
- febePrefs.setBoolPref("extensions.febe.restorePhishingData",false);
- return true;
- }//febeRestorePhishingDataFinish()
-
- function febeRestoreSearchPlugins(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("searchPlugins*.fbu",84)){return true};
-
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(72,febeBUdate)){
- if(!febeInitDir()){return false;}
- var OK = new Boolean(true);
- try{
- var batchFileName = "searchPlugins";
- var tmpRestName = "search-plugins.fbu";
-
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the archive to the tmp directory
- febeCopyFile(febePathName,febeTmpDir.path,tmpRestName);
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEunzip.exe\"");
- batchlines.push("SET SRCNAME=\"..\\"+tmpRestName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("RD /S /Q %TMP2DIR%");
- batchlines.push("MD %TMP2DIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -o %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
-
- if(febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- febeSubRootDir = batchFileName;
- febeDestDir = febeProfDir.clone();
- febeDirCopy(febeTmpDir.path+"\\"+batchFileName);
- }//if
- }else{
- throw febeMsg[97];
- }//if
-
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){
- febeAlert(febeMsg[85]);
- }else{
- febeAlert(febeMsg[46]);
- }
- }
- return true;
- }//febeRestoreSearchPlugins()
-
- function febeRestoreBrowserHistory(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("history*.dat",86)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(73,febeBUdate)){
- febePrefs.setBoolPref("extensions.febe.restoreHistory",true);
- febePrefs.setCharPref("extensions.febe.restHistory.srcName",febePathName);
- febeAlert(febeMsg[106]);
- febeRestartFx();
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreBrowserHistory()
-
- function febeRestoreBrowserHistoryFinish(){
- febeSetMsgs();
- if(!febeInitDir()){return false;}
- var OK = new Boolean(true);
- try{
- var febePathName = febePrefs.getCharPref("extensions.febe.restHistory.srcName");
- febeCopyFile(febePathName,febeProfDir.path,"history.dat");
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){febeAlert(febeMsg[87])};
- febePrefs.setBoolPref("extensions.febe.restoreHistory",false);
- return true;
- }//febeRestoreBookmarksFinish
-
- function febeRestoreFormFillHistory(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("formhistory*.dat",88)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(74,febeBUdate)){
- febeCopyFile(febePathName,febeProfDir.path,"formhistory.dat");
- febeAlert(febeMsg[89]);
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestoreFormFillHistory()
-
- function febeRestorePermissions(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("hostperm*.1",117)){return true};
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(118,febeBUdate)){
- febeCopyFile(febePathName,febeProfDir.path,"hostperm.1");
- febeAlert(febeMsg[119]);
- }else{
- febeAlert(febeMsg[46]);
- }
- return true;
- }//febeRestorePermissions()
-
- function febeRestoreUDBu(){
-
- return true;
- }//febeRestoreUDBu()
-
- function febeRestoreProfile(){
- if(!febeInitDir()){return false;}
- febePathName = ""
- if(!febePickFile("profile*.fbu",90)){return true};
-
- var prefName = "extensions.febe.selectedRestoreProfile";
- febePrefs.setCharPref(prefName,febePathName);
-
- var prefName = "extensions.febe.selectedRestoreProfileName";
- febePrefs.setCharPref(prefName,febePrName);
-
- // Open restore profile window
- febeWin = window.openDialog("chrome://febe/content/febeProfile.xul", "FEBE", "chrome,alwaysRaised,centerscreen");
- return true;
- }//febeRestoreProfile()
-
- function febeProfileWindowInit(){
- if(!febeInitDir()){return false;}
- febeWin = this.window.document;
-
- febeProfList = [];
- febeGetProfileList(febeProfList);
-
- febeWin.getElementById("febeCurrentProfileText").value = febeProfName ;
-
- var prefName = "extensions.febe.selectedRestoreProfile";
- var febePathName = febePrefs.getCharPref(prefName); // Full path to backed up profile
-
- var prefName = "extensions.febe.selectedRestoreProfileName";
- var febePrName = febePrefs.getCharPref(prefName);
- febeWin.getElementById("febeSelectedProfileText").value = febePrName;
-
- for(var i = 0; i < febeProfList.length; i++){
- var item = febeWin.getElementById("febeProfileList")
- .insertItemAt ( i, febeProfList[i].Name , febeProfList[i].Path)
- if(item.label == febeProfName ){item.disabled = true;}
- }//for
-
- // If there is only one profile, display help message
- if(febeProfList.length == 1){
- window.openDialog("chrome://febe/content/febeProfileRestoreMsg.xul", "FEBE Alert", "chrome,modal,dialog=yes,alwaysRaised,centerscreen,resizable");
- }//if
- return true;
- }//febeProfileWindowInit()
-
- function febeProfileSelected(pIndex){
- febeWin = this.window.document;
- if(!febeWin.getElementById("febeProfileList").selectedItem){ // Profile selected?
- febeAlert(febeMsg[48]);
- return false;
- }//if
-
- var item = febeWin.getElementById("febeProfileList").selectedItem.label;
- if(item == febeProfName ){
- febeAlert(febeMsg[6]);
- return false;
- }//if
- febeWin.getElementById("febeDestinationProfileText").value = item;
- var pIndex = febeWin.getElementById("febeProfileList").selectedIndex;
- return true;
- }//febeProfileSelected()
-
- function febeGetProfileList(febeProfList){
- // Create pointer to Firefox root directory (where the profile directories reside)
- var files = Components.classes["@mozilla.org/file/directory_service;1"]
- .getService(Components.interfaces.nsIProperties)
- .get("ProfD", Components.interfaces.nsIFile);// Was "DefProfRt"
- var parentDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- parentDir.initWithPath(files.parent.path);
-
- var entries = parentDir.directoryEntries;
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsILocalFile);
- if(!entry.isDirectory()){continue;}
- var p = new febeProfileObj;
- var x = entry.leafName;
- var P = x.indexOf(".");
- p.Name = x.substring(P+1);
- p.Path = entry.path;
- febeProfList.push(p);
- }//while
- return true;
- }//febeGetProfileList()
-
- function febeStartProfileRestore(){
- if(!febeInitDir()){return false;}
- febeWin = this.window.document;
- if(!febeProfileSelected()){return false};
- var pIndex = febeWin.getElementById("febeProfileList").selectedIndex;
- febeWin.getElementById("febeProfileResoreBox").hidden = false;
-
- var prefName = "extensions.febe.selectedRestoreProfile";
- febePathName = febePrefs.getCharPref(prefName); // Full path to backed up profile
- febeGetBuDate(febePathName);
- if(febeConfirmRestore(75,febeBUdate)){
- if(!febeInitDir()){return false;}
-
- // Remove contents of destination profile
- var destProfile = febeProfList[pIndex].Path;
- pDestDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- pDestDir.initWithPath(destProfile);
- var entries = pDestDir.directoryEntries;
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsILocalFile);
- entry.remove(true);
- }//while
- var OK = new Boolean(true);
- try{
- var batchFileName = "profileRestore";
- var tmpRestName = batchFileName+".fbu";
- var batchlines = [];
- if(febePlatform == 1){ // Windows
- // Copy the archive to the temp directory, renaming it
- febeCopyFile(febePathName,febeTmpDir.path,tmpRestName)
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEunzip.exe\"");
- batchlines.push("SET SRCNAME=\"..\\"+tmpRestName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("RD /S /Q %TMP2DIR%");
- batchlines.push("MD %TMP2DIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -o %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeUnZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfList[pIndex].Path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeUnZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfList[pIndex].Path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
-
- if(febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- febeSubRootDir = batchFileName;
- febeDestDir = pDestDir.clone();
- febeTmpDir.append(batchFileName);
- var entries = febeTmpDir.directoryEntries;
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsILocalFile);
- entry.copyTo(pDestDir,null);
- }//while
- }//if
- }else{
- throw febeMsg[102];
- }//if
- }catch(e){
- var msg = febeMsg[169];
- OK = false;
- febeFatal(e,msg);}
- if(OK){
- febeAlert(febeMsg[91]);
- }else{
- febeAlert(febeMsg[46]);
- }//if
- }//if
- return true;
- }//febeStartProfileRestore()
-
- function febeRestoreUDBU(index){
- var udbuLabel = febeUDBuList[index].Label;
- var udbuDescription = febeUDBuList[index].Description;
- var udbuType = parseInt(febeUDBuList[index].Type);
- var udbuPath = febeUDBuList[index].Path;
- febePathName = ""
- if(!febeInitDir()){return false;}
- var fMask = udbuLabel.replace(/ /g,"?")+"*";
- if(udbuType == 1){fMask = udbuLabel.replace(/ /g,"?")+"*.fbu";}
- if(!febePickFile(fMask,161)){return false;};
- febeGetBuDate(febePathName);
- febeSetMsgs();
- febeMsg[163] = febeMsg[163].replace(/%fname%/,udbuDescription);
- febeMsg[164] = febeMsg[164].replace(/%fname%/,udbuDescription);
- if(udbuType == 0){
- // File restore is a straight copy
- if(febeConfirmRestore(163,febeBUdate)){
- febeCopyFile(febePathName,febeParent(udbuPath),febeLeafname(udbuPath));
- febeAlert(febeMsg[164]);
- }else{
- febeAlert(febeMsg[46]);
- }//if
- }else{
- // Restore backed up folder
- var batchFileName = "UDBU";
- var tmpRestName = "UDBUrestore.fbu";
- var batchlines = [];
- if(febeConfirmRestore(163,febeBUdate)){
- febeRestoreProgress();
- if(febePlatform == 1){ // Windows
- // Copy the archive to the tmp directory
- febeCopyFile(febePathName,febeTmpDir.path,tmpRestName);
-
- batchlines.push("SET TMPDIR="+"\""+febeTmpDir.path+"\"");
- batchlines.push("SET TMP2DIR="+"\""+batchFileName+"\"");
- batchlines.push("SET ZFILE=\"..\\FEBEunzip.exe\"");
- batchlines.push("SET SRCNAME=\"..\\"+tmpRestName+"\"");
- batchlines.push(febeTmpDir.path.slice(0,2)); // Set dirve letter (i.e., "C:")
- batchlines.push("CD %TMPDIR%");
- batchlines.push("RD /S /Q %TMP2DIR%");
- batchlines.push("MD %TMP2DIR%");
- batchlines.push("CD %TMP2DIR%");
- batchlines.push("%ZFILE% -o %SRCNAME%");
- }//if
- if(febePlatform == 2){ // *nix
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
- if(febePlatform == 3){ // Mac
- batchlines.push("ZFILE="+"\""+febeZipFile.path+"\"");
- batchlines.push("SRCNAME=\""+febePathName+"\"");
- batchlines.push("DESTDIR="+"\""+febeProfDir.path+"\"");
- batchlines.push("export ZFILE");
- batchlines.push("export SRCNAME");
- batchlines.push("export DESTDIR");
- batchlines.push("cd \"$DESTDIR\"");
- batchlines.push("`\"$ZFILE\" -o \"$SRCNAME\"`");
- }//if
-
- if(febeGoBatch(batchFileName,batchlines)){
- if(febePlatform == 1){
- // Create pointer to destination file
- febeDestDir = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- febeDestDir.initWithPath(udbuPath);
- febeSubRootDir = batchFileName;
- febeDirCopy2(febeTmpDir.path+"\\"+batchFileName,batchFileName);
- }//if
- }else{
- throw febeMsg[97];
- }//if
- febeAlert(febeMsg[164]);
- }else{
- febeAlert(febeMsg[46]);
- }//if
- }//if
- return true;
- }//febeRestoreUSBU()
-
- function febeDirCopy2(sourceDir,batchFileName){
- // Recursively copy individual files and sub-directories to a destination directory
- // Very tricky code ... could be written better. So little time, so much to do
- var tmp = "sourceDir: "+sourceDir;
- tmp += "\nfebeSubRootDir: "+febeSubRootDir;
- tmp += "\nfebeDestDir: "+febeDestDir.path;
-
- var aFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- if (!aFile) return false;
-
- aFile.initWithPath(sourceDir);
- var entries = aFile.directoryEntries;
-
- while(entries.hasMoreElements()){
- var entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- var src = entry.path;
- var p = src.indexOf(febeSubRootDir)
- if(p == -1){continue;}
- if(entry.isDirectory()){
- febeDirCopy2(src,batchFileName);
- }else{
- var parentPath = entry.parent.path;
- var dest = febeDestDir.path+"\\"+parentPath.substring(p);
- var re = "\\"+batchFileName+"";
- ;
- var file = entry.leafName;
- febeCopyFile(src,dest.replace(re,"\\"),file);
- }//if
- }//while
- return true;
- }//febeDirCopy2()
-
- // ------------------ End of Restore Functions ------------
-
- //alert("febe.js loaded");